package com.ktgj.other.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.other.domain.EtSceneryimage;
import com.ktgj.other.service.IEtSceneryimageService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/sceneryimage")
public class EtSceneryimageController extends BaseController
{
    @Autowired
    private IEtSceneryimageService etSceneryimageService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:list")
    @GetMapping("/list")
    public TableDataInfo list(EtSceneryimage etSceneryimage)
    {
        startPage();
        List<EtSceneryimage> list = etSceneryimageService.selectEtSceneryimageList(etSceneryimage);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EtSceneryimage etSceneryimage) throws IOException
    {
        List<EtSceneryimage> list = etSceneryimageService.selectEtSceneryimageList(etSceneryimage);
        ExcelUtil<EtSceneryimage> util = new ExcelUtil<EtSceneryimage>(EtSceneryimage.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:query")
    @GetMapping(value = "/{sceneryimageid}")
    public AjaxResult getInfo(@PathVariable("sceneryimageid") Long sceneryimageid)
    {
        return AjaxResult.success(etSceneryimageService.selectEtSceneryimageById(sceneryimageid));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EtSceneryimage etSceneryimage)
    {
        return toAjax(etSceneryimageService.insertEtSceneryimage(etSceneryimage));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EtSceneryimage etSceneryimage)
    {
        return toAjax(etSceneryimageService.updateEtSceneryimage(etSceneryimage));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "other:sceneryimage:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sceneryimageids}")
    public AjaxResult remove(@PathVariable Long[] sceneryimageids)
    {
        return toAjax(etSceneryimageService.deleteEtSceneryimageByIds(sceneryimageids));
    }

    /**
     * 景点图片列表
     * */
    @PostMapping("/pictureUrl")
    public AjaxResult pictureUrl(@RequestBody Map<String, Object> map){
        Long id = Long.valueOf(map.get("id").toString());
        List<String> stringList = etSceneryimageService.pictureUrl(id);
        return AjaxResult.success(stringList);
    }
}
